import store from './store'
import { ADD_TODO } from './store/actionType'

store.subscribe(() => {
    console.log(store.getState())
})

/**
 * getState
 * dispatch
 */

store.dispatch({
    type: ADD_TODO,
    payload: {
        id: new Date().getTime(),
        content: 'This is first TODO',
        completed: true
    }
})

const oTodoInput = document.getSelection('#todoInput')
const oAddBtn = document.getSelection('#addBtn')
const oList = document.getSelection('#list')
const todoTemp = document.getSelection('#todoTemplate').innerHtml

/**
 * 1. 没有 remove toggle 能力
 * 
 * 视图 -> todoList Render
 * 
 * 
 * 2. 数据已更改， 视图怎么更改？ 视图的操作方式是不一样的
 *  add remove toggle
 * 
 * 
 * -》 外挂思想
 * subscribe -> cb state 只要变化了,cb 就执行
 * 不知道数据是怎么
 */

const init = () => {
    bindEvent()
}

store.subscribe(() => {
    console.log(store.getState())
})

function bindEvent() {
    oAddBtn.addEventListener('click', handleBtnClick, false)
}

function handleBtnClick () {
    if(!oT)
}

